/**
 * Created by yihua on 2017/2/12.
 */



$(document).ready(function () {
    deleteGoods();
});


function deleteGoods() {
    $(".delgoods").each(function () {
        var id = $(this).eq(0)[0].id;

        //console.log(id);
        $(this).click(function () {
            console.log('++++')
            $("#deleteModal").modal("show");
            $("#delete_confirm").unbind('click').click(function () {
                $.ajax({
                    url: '/home/shop/deletegoods',
                    timeout: 100000,
                    type: 'get',
                    dataType: 'json',
                    data: {
                        'goods_id': id
                    },
                    success: function (rs) {
                        if (rs.errno != 0) {
                            toastr.error(rs.errmsg, '', {positionClass: 'toast-bottom-center'});
                        } else {
                            toastr.success(rs.errmsg, '', {positionClass: 'toast-bottom-center'});
                            window.location.reload();
                        }
                    },
                    error: function () {
                        toastr.error('系统错误', '', {positionClass: 'toast-bottom-center'});
                    }
                });
            });

        });

    });
}